<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String BASE_PATH = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <link href="${BASE_PATH}static/css/commen.css" rel="stylesheet">
    <link href="${BASE_PATH}static/css/public.css" rel="stylesheet">
    <link href="${BASE_PATH}static/css/jujiao.css" rel="stylesheet">
</head>
<body>

<!--头部-->
<div class="g_coun_head">
    <div class="g_coun_head_main clearfix">
        <a class="g_c_h_m_logo fl" href="${BASE_PATH}index.jsp"></a>
        <ul class="g_c_h_m_lists fl">
            <li><a href="${BASE_PATH}index.jsp">首页</a></li>
            <li><a href="${BASE_PATH}businessRisk.jsp">企业风险榜单</a></li>
            <li class="active"><a href="${BASE_PATH}focus.jsp">企业风险聚焦</a></li>
        </ul>
        <div class="g_c_h_m_user fr">
			<span class="busRis_sear fl">
				<input type="text" class="busRis_inpSear fl" placeholder="请输入企业名、人名或其他关键词">
				<input type="button" class="busRis_btnSear fl" value="查处罚">
			</span>
            <a href="" class="g_c_h_m_login fl">登录</a>
            <a href="" class="g_c_h_m_registe fl active">免费注册</a>
        </div>
    </div>
    <p class="g_coun_h_shandow"></p>
</div>
<!--聚焦内容区域-->
<div class="risk_focus">
    <!--聚焦内容左侧区域-->
    <div class="focus_left fl">
        <!--聚焦内容左侧分类-->
        <div class="focus_classify">
            <a href="#" class="icon1 no1" onclick="comyRiskFocus(null,1)" >全部</a>
            <a href="#" class="icon2" onclick="comyRiskFocus(1,1)">环保</a>
            <a href="#" class="icon3" onclick="comyRiskFocus(2,1)">金融</a>
            <a href="#" class="icon4" onclick="comyRiskFocus(3,1)">司法</a>
            <a href="#" class="icon5" onclick="comyRiskFocus(4,1)">医药</a>
            <a href="#" class="icon6" onclick="comyRiskFocus(5,1)">能源</a>
            <a href="#" class="icon7" onclick="comyRiskFocus(6,1)">教育</a>
        </div>
        <!--聚焦内容左侧分类内容-->
        <div class="focus_content" id="focus_con"></div>
    </div>
    <!--右侧内容区域-->
    <div class="focus_right">
        <!--本周热门事件-->
        <div class="focus_hot">
            <p class="title">本周热点事件</p>
            <!-- 热门事件轮播图片-->
            <div class="swiper-container">
                <div class="swiper-wrapper" id="swiper_wra">
                </div>
                <!-- 左右切换 -->
                <div class="swiper-button-next swiper-button-white"></div>
                <div class="swiper-button-prev swiper-button-white"></div>
            </div>
        </div>
        <!--企业负面舆情排行榜-->
        <div class="focus_ranking">
            <p class="title">企业负面舆情排行榜</p>
            <div class="focus_rankcont">
                <ul id="negPubSent"></ul>
            </div>
        </div>
    </div>
    <div class="clear"></div>
</div>
<div class="g_coun_foot">
    <div class="g-coun_borBott">
        <div class="g_coun_f_main">
            <div class="g_coun_f_m_top clearfix">
                <div class="g_coun_f_m_t_l fl">
                    <h2 class="g_coun_f_m_t_title fl">企业风险</h2>
                    <ul class="g_coun_f_m_t_list fl">
                        <li>关于我们</li>
                        <li>免责声明</li>
                        <li>服务协议</li>
                        <li>权利通知</li>
                        <li>意见反馈</li>
                        <li>数据服务</li>
                        <li>常见问题</li>
                        <li> 版权声明</li>
                    </ul>
                </div>
                <div class="g_coun_f_m_t_c fl">
                    <h2 class="g_coun_f_m_t_title">联系我们</h2>

                    <p>企业邮箱：xxxxxx@xxxxx.com</p>

                    <p>客服电话：888888888</p>
                </div>
                <div class="g_coun_f_m_t_r fr">
                    <div class="fl g_coun_f_m_t_r_l">
                        <p class="g_coun_f_m_t_r_l_title">微信公众号</p>

                        <p class="g_coun_f_m_t_r_l_pic"></p>
                    </div>
                    <div class="fl g_coun_f_m_t_r_l">
                        <p class="g_coun_f_m_t_r_l_title">征信查APP</p>

                        <p class="g_coun_f_m_t_r_l_pic"></p>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="g-coun_borTop">
        <div class="g_coun_f_main">
            <div class="g_coun_f_m_bottom">
                <p>版权所有：xxxxxxxxx@2016 JINDIDATA 京ICP备 xxxxxxx</p>

                <p>京公网安备 11010802021795号</p>
            </div>
        </div>
    </div>
</div>
</body>
<script src="${BASE_PATH}static/js/jquery-1.10.2.min.js"></script>
<!-- Swiper JS -->
<script src="${BASE_PATH}static/js/swiper.min.js"></script>
<script>
    $(function(){
        comyRiskFocus(null,1);//企业风险聚焦
        negPubSent();//企业负面舆情排行榜
        hotEvent();//本周热点事件接口
    })
    function comyRiskFocus(type,order){
        var index = "";
        if(type == null){
            index = 0;
        }else {
            index = type;
        }
        $(".focus_classify").find("a").eq(index).addClass("no1");
        $(".focus_classify").find("a").eq(index).siblings("a").removeClass("no1");
        var pageNo = order;//查询第几页数
        var riskFocusUrl = '${BASE_PATH}risk/businessRiskMatters';//企业风险聚焦接口
        var data= {
            pageNo:pageNo,//查询第几页数
            pageSize:8,//每页显示记录数
            type:type//搜索类型type 空 全部 1 环保 2 金融 3 司法 4 医药 5 能源 6 教育
        }
        $.ajax({
            url:riskFocusUrl,
            type:'post',
            data:data,
            dataType:'json',
            success:function(data){
                if(data.code==-1){
                    alert("查询失败");
                    return;
                }
                var pageHtml = //分页
                        '<div class="focus_page page clearfix">'+
                        '	<ul class="fl">';
                var page = Math.ceil(data.totalRow / data.pageSize);
                var currPageNo = data.pageNumber;
                var minPageNo = 1;
                var maxPageNo = page;
                if (!pageNo || pageNo == null || pageNo == "") {
                    pageNo = 1;
                } else if (pageNo > page) {
                    pageNo = page;
                }
                /* if (maxPageNo > 10) {
                 if (pageNo > 5) {
                 if (maxPageNo - pageNo <= 4) {
                 minPageNo = maxPageNo - 9;
                 } else {
                 minPageNo = pageNo - 5;
                 maxPageNo = pageNo + 4;
                 }
                 } else {
                 maxPageNo = 10;
                 }
                 } */
                for (var int = 1; int <= page; int++) {
                    // 获取页码和当前页码
                    if (data.pageNumber == int) {
                        pageHtml+= "<li class='page_action'>" + int + "</li>";
                    } else {
                        if (int >= minPageNo && int <= maxPageNo) {
                            pageHtml+= "<li onclick='comyRiskFocus("+ type +"," + int + ")'>" + int + "</li>";
                        }
                    }
                }
                // 判断是否是第一页
                if (data.pageNumber != 1) {
                    pageHtml+= "<li onclick='comyRiskFocus("+ type +"," + (data.pageNumber - 1) + ")'>&lt;</li>";
                }
                // 页数是否已加载完成
                // 判断是否是最后一页
                if (data.pageNumber != page) {
                    pageHtml+= "<li onclick='comyRiskFocus("+ type +"," + (parseInt(data.pageNumber) + 1) + ")'>&gt;</li>";
                }
                pageHtml+=//
                        '	</ul>'+
                        '	<p class="fr page_all">共&nbsp;<span class="page_num">'+ data.totalRow +'</span>&nbsp;条记录</p>'+
                        '</div>';
                var riskFocusHtml='<ul class="focus_con_list">';//
                $.each(data.data,function(i,item){
                    var typeF = '';//空 全部 1 环保 2 金融 3 司法 4 医药 5 能源 6 教育
                    if(item.type==1){
                        typeF = '环保';
                    }else if(item.type==2){
                        typeF = '金融';
                    }else if(item.type==3){
                        typeF = '司法';
                    }else if(item.type==4){
                        typeF = '医药';
                    }else if(item.type==5){
                        typeF = '能源';
                    }else if(item.type==6){
                        typeF = '教育';
                    }
                    riskFocusHtml +=//
                            '<li>'+
                            '	<a href="${BASE_PATH}focus_con.jsp" title="" class="con fl">'+ item.title +'</a>'+
                            '	<span class="tent" onclick="comyRiskFocus('+ item.type +',1)">'+ typeF +'</span>'+
                            '	<a href="#" onclick="jumpDetail('+ item.id +');" class="text">'+ item.synopsis +'</a>'+
                            '	<p class="fl time">发布时间：'+ item.publishtime +'</p>'+
                            '	<p class="fl loca">事件位置： '+ item.position +'</p>'+
                            '	<p class="fl assoc">关联企业：';
                    for(var j=0;j<item.cognate.length;j++){
                        riskFocusHtml +='<a href="#" onclick="jumpDetail('+ item.cognate[j].id +');">'+ item.cognate[j].company +'</a>';
                    }
                    riskFocusHtml +=//
                            '</p>'+
                            '</li>';
                })
                riskFocusHtml += '</ul>'+pageHtml;
                $("#focus_con").html(riskFocusHtml);
            },
            error:function(error){
                alert("error");
                console.log(error);
            }
        })
    }
    //本周热点事件
    function hotEvent(){
        var hotEventUrl = '${BASE_PATH}risk/hotIssueThisWeek';//本周热点事件接口
        $.ajax({
            url:hotEventUrl,
            type:'post',
            async: false,
            dataType:'json',
            success:function(data){
                var swiperHtml = ""
                $.each(data.data,function(i,item){
                    swiperHtml += '<div class="swiper-slide"><img src="'+ item.imgpath +'"><span>'+ item.title +'</span></div>';
                })
                $("#swiper_wra").html(swiperHtml);
            }
        })
        <!-- Initialize Swiper -->
        /* 本周热点事件轮播图 */
        var swiper = new Swiper('.swiper-container', {
            pagination: '.swiper-pagination',
            paginationClickable: true,
            nextButton: '.swiper-button-next',
            prevButton: '.swiper-button-prev',
            spaceBetween: 30,
            effect: 'fade'
        });
    }
    //企业负面舆情排行榜
    function negPubSent(){
        var negPubSentUrl = '${BASE_PATH}risk/negativePublicOptionList';//企业负面舆情排行榜接口
        $.ajax({
            url:negPubSentUrl,
            type:'post',
            dataType:'json',
            success:function(data){
                var negPubSentHtml = ""
                $.each(data.data,function(i,item){
                    var ii = parseInt(i)+1;
                    if(ii<4){
                        negPubSentHtml += '<li><span class="mboer fl">'+ ii +'</span><p class="conp fl"><a href="#">'+ item.company +'</a></p><p class="conp2"><b>'+ item.number +'</b>篇</p></li>';
                    }else {
                        negPubSentHtml += '<li><span class="fl">'+ ii +'</span><p class="conp fl"><a href="#">'+ item.company +'</a></p><p class="conp2"><b>'+ item.number +'</b>篇</p></li>';
                    }
                })
                $("#negPubSent").html(negPubSentHtml);
            }
        })
    }
    //跳转到企业风险聚焦详情页面
    function jumpDetail(id){
        //window.location.href='focus_con.html';
        window.location.href='${BASE_PATH}focus_con.jsp?id='+id;
    }
</script>
</html>
